package Text_76;

import java.io.FileOutputStream;
import java.io.IOException;

public class Code {

	public static void main(String[] args) throws IOException {
		//程序写入本地文件中，FileOutputStream
        //文件不存在会自动创建，但要保证父级路径正确

        FileOutputStream fos = new FileOutputStream("src\\Day10\\a.txt");
        //写入
        //1.
        //fos.write(97);
        //System.out.println(fos);
        //2.
        byte[]  bytes = {97,98,99,100,101,102};
       // fos.write(bytes);
        //3.
        //参数一：数组
        //参数二：数组索引
        //参数三：获取的元素个数
        fos.write(bytes,1,3);
        //释放
        fos.close();
        //想要续写就要打开续写开关，创建对象的第二个参数 true
        FileOutputStream fos1 = new FileOutputStream("src\\Day10\\b.txt");
        String str = "asdf";
        //String -->byte[]
        byte[] bytes1 = str.getBytes();
        fos1.write(bytes1);
        //fos1.close();
//        for(byte b:bytes1){
//            System.out.println(b);
//        }
//        System.out.println(Arrays.toString(bytes1));
        //换行
        String w = "\r\n";
        byte[] bytes3 = w.getBytes();
        fos1.write(bytes3);
        //续写
        String str2 = "1234";
        byte[] bytes2 = str2.getBytes();
        fos1.write(bytes2);
        fos1.close();

	}

}
